package com.bafa.front.presentationbeans.playerhistory;

import com.bafa.front.presentationbeans.MatchBean;
import com.bafa.front.presentationbeans.MatchListBean;
import com.bafa.objects.player.Player;
import com.bafa.objects.player.PlayerMatch;
import com.bafa.services.RetrieveServices;

public class PlayerHistoryBean {

	
	private String name;
	private int totalGoals;
	private TeamListGoalsBean teamGoals;
	private DivisionListGoalsBean divisionGoals;
	private int numberOfMatchesScored;
	private int numberOfHattricks;
	private MatchListBean hattrickMatches;
	private MatchBean mostGoalsInOneMatch;
	private int mostGoalsInMatch;
	public PlayerHistoryBean(String name) {
		name.replaceAll("%20"," ");
		Player player = RetrieveServices.getPlayer(name);
		teamGoals = new TeamListGoalsBean(name);
		divisionGoals = new DivisionListGoalsBean(name);
		this.name = name;
		this.totalGoals = player.getTotalGoals();
		numberOfMatchesScored = player.getMatchGoals().size();
		PlayerMatch[] matches = (PlayerMatch[])player.getMatchGoals().values().toArray(new PlayerMatch[numberOfMatchesScored]);
		hattrickMatches = new MatchListBean();
		for(int i=0;i<numberOfMatchesScored;i++){
			if(matches[i].getGoals()>2){
				numberOfHattricks = numberOfHattricks+1;
				hattrickMatches.addMatchBean(new MatchBean(RetrieveServices.getMatch(matches[i].getMatch())));
			}
			if(matches[i].getGoals()>mostGoalsInMatch){
				mostGoalsInOneMatch = new MatchBean(RetrieveServices.getMatch(matches[i].getMatch()));
				mostGoalsInMatch = matches[i].getGoals();
			}
		}
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public TeamListGoalsBean getTeamGoals() {
		return teamGoals;
	}

	public void setTeamGoals(TeamListGoalsBean teamGoals) {
		this.teamGoals = teamGoals;
	}

	public int getTotalGoals() {
		return totalGoals;
	}

	public void setTotalGoals(int totalGoals) {
		this.totalGoals = totalGoals;
	}

	public DivisionListGoalsBean getDivisionGoals() {
		return divisionGoals;
	}

	public void setDivisionGoals(DivisionListGoalsBean divisionGoals) {
		this.divisionGoals = divisionGoals;
	}

	public int getNumberOfHattricks() {
		return numberOfHattricks;
	}

	public void setNumberOfHattricks(int numberOfHattricks) {
		this.numberOfHattricks = numberOfHattricks;
	}

	public int getNumberOfMatchesScored() {
		return numberOfMatchesScored;
	}

	public void setNumberOfMatchesScored(int numberOfMatchesScored) {
		this.numberOfMatchesScored = numberOfMatchesScored;
	}

	public MatchBean getMostGoalsInOneMatch() {
		return mostGoalsInOneMatch;
	}

	public int getMostGoalsInMatch() {
		return mostGoalsInMatch;
	}

	public MatchListBean getHattrickMatches() {
		return hattrickMatches;
	}

	public void setHattrickMatches(MatchListBean hattrickMatches) {
		this.hattrickMatches = hattrickMatches;
	}

	public void setMostGoalsInMatch(int mostGoalsInMatch) {
		this.mostGoalsInMatch = mostGoalsInMatch;
	}

	public void setMostGoalsInOneMatch(MatchBean mostGoalsInOneMatch) {
		this.mostGoalsInOneMatch = mostGoalsInOneMatch;
	}
}
